import type { RequiredDeep } from 'type-fest'

import { ajax } from '@/utils'

import type { components } from '../schema'
import type { IDeleteReq, IExportRes } from '../type'

/**
 * 操作日志接口
 */
export const operLogApi = {
  /**
   * 获取操作日志分页
   */
  getOperLogPage(data: IGetOperLogPageReq): Promise<IGetOperLogPageRes> {
    return ajax.post('/monitor/log/oper/page', data)
  },
  /**
   * 导出操作日志分页
   */
  exportOperLogPage(data: IGetOperLogPageReq): Promise<IExportRes> {
    return ajax.post('/monitor/log/oper/export', data)
  },
  /**
   * 删除操作日志
   */
  deleteOperLog(data: IDeleteReq) {
    return ajax.delete('/monitor/log/oper/delete', { data })
  },
  /**
   * 清空操作日志
   */
  clearOperLog() {
    return ajax.delete('/monitor/log/oper/clear')
  }
}

export type IGetOperLogPageReq = components['schemas']['FindOperLogPageDTO']
export type IGetOperLogPageRes = RequiredDeep<
  components['schemas']['FindOperLogPageVO']['data']
>
export type IOperLogPageItem = IGetOperLogPageRes['list'][0]
